import arcade

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600



def fk(x,y):
    arcade.draw_rectangle_filled(x, y, 60, 60, arcade.color.BLACK)


def on_draw(time):
    arcade.start_render()
    fk(on_draw.start_x, on_draw.start_y)
    on_draw.start_x += 50
    on_draw.start_y += 50
    if(on_draw.start_x <= 0):
        on_draw.start_x += 50
    if(on_draw.start_y <=0):
        on_draw.start_y += 50
    if(on_draw.start_x >= 800):
        on_draw.start_x -= 50
    if(on_draw.start_y >= 600):
        on_draw.start_y -= 50

on_draw.start_x = 400
on_draw.start_y = 10


def main():
    arcade.open_window(SCREEN_WIDTH, SCREEN_HEIGHT, "函数画图")
    arcade.set_background_color(arcade.color.BEIGE)
    arcade.schedule(on_draw, 1/120)
    arcade.run()


if __name__ == "__main__":
    # 调用main()函数
    main()
